{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "2751f7f8",
   "metadata": {},
   "source": [
    "----------------------\n",
    "* 2022-11-14 week13\n",
    "* Python 学习记录\n",
    "* 记录人：刘志勇\n",
    "----------------------\n",
    "\n",
    "# Head First Python练习\n",
    "\n",
    "## 1.list\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "934b1279",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i\n",
      "i\n",
      "a\n"
     ]
    }
   ],
   "source": [
    "# A-1\n",
    "\n",
    "vowels = ['a', 'e', 'i', 'o', 'u' ]\n",
    "word = \"Milliways\"\n",
    "for letter in word:\n",
    "    if letter in vowels:\n",
    "        print(letter)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "685c8723",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i\n",
      "i\n",
      "a\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "['i', 'i', 'a']"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# A-2\n",
    "vowels = ['a', 'e', 'i', 'o', 'u' ]\n",
    "found = []\n",
    "word = \"Milliways\"\n",
    "for letter in word:\n",
    "    if letter in vowels:\n",
    "        print(letter)\n",
    "        found.append(letter)\n",
    "found\n",
    " "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "ae394d8c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Don't panic!\n",
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n"
     ]
    }
   ],
   "source": [
    "# A-3\n",
    "phrase =\"Don't panic!\"\n",
    "plist =list(phrase)\n",
    "print(phrase)\n",
    "print(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "773ccc25",
   "metadata": {},
   "outputs": [],
   "source": [
    "plist.remove('D')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "abb16f15",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "plist"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "2f4a050e",
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(3):\n",
    "    plist.pop()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "7103f47d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['o', 'n', \"'\", 't', ' ', 'p', 'a', 'n']"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "plist"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "dc54b575",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'n'"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "plist[-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "e7125c0f",
   "metadata": {},
   "outputs": [],
   "source": [
    "plist.insert(3,plist[-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "bb2eb84e",
   "metadata": {},
   "outputs": [],
   "source": [
    "plist.insert(2,plist[-3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "4ddc3bfc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['o', 'n', 'p', \"'\", 'n', 't', ' ', 'p', 'a', 'n']"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "plist"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "fd9ff427",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Don't panic!\n",
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n",
      "['o', 'n', ' ', 't', 'a', 'p']\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'on tap'"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# A-3整理\n",
    "phrase =\"Don't panic!\"\n",
    "plist =list(phrase)\n",
    "print(phrase)\n",
    "print(plist)\n",
    "for i in range(4):\n",
    "    plist.pop()\n",
    "plist.pop (0) # 移除最后一个元素\n",
    "plist.remove(\"'\") # 去掉元素\n",
    "plist\n",
    "plist.extend([plist.pop(), plist.pop()])\n",
    "plist\n",
    "plist.insert(2,plist.pop(3))  #元素插到指定位置\n",
    "print(plist)\n",
    "## 列表元素的合并 ： ''.join\n",
    "''.join(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "95322e35",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Don't panic!\n",
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n"
     ]
    }
   ],
   "source": [
    "# A-4 列表的切片和取值 on tap\n",
    "phrase =\"Don't panic!\"\n",
    "plist =list(phrase)\n",
    "print(phrase)\n",
    "print(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "8ced8a47",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'on tap'"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "''.join([plist[1],plist[2],plist[5],plist[4],plist[-5],plist[-6]])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cdc0f13f",
   "metadata": {},
   "source": [
    "# 课后作业\n",
    "## Chapter 3：Structured Data练习"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1f45a9c5",
   "metadata": {},
   "source": [
    "## 频度计数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3c110377",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide a word to search for vowels:elegance\n",
      "a was found 1 time(s).\n",
      "e was found 3 time(s).\n",
      "i was found 0 time(s).\n",
      "o was found 0 time(s).\n",
      "u was found 0 time(s).\n"
     ]
    }
   ],
   "source": [
    "vowels = ['a','e','i','o','u']\n",
    "word = input(\"Provide a word to search for vowels:\")\n",
    "\n",
    "found = {}  # 创建一个空字典\n",
    "# 将与键（各个元音）关联的值初始化为0\n",
    "found['a'] = 0    \n",
    "found['e'] = 0\n",
    "found['i'] = 0\n",
    "found['o'] = 0\n",
    "found['u'] = 0\n",
    "\n",
    "for letter in word:\n",
    "    if letter in vowels:\n",
    "        found[letter] +=1\n",
    "        \n",
    "for k,v in sorted(found.items()):\n",
    "    print(k,'was found',v,'time(s).')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7744670e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide a word to search for vowels:apple\n"
     ]
    },
    {
     "ename": "KeyError",
     "evalue": "'a'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "Input \u001b[1;32mIn [3]\u001b[0m, in \u001b[0;36m<cell line: 6>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      6\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m letter \u001b[38;5;129;01min\u001b[39;00m word:\n\u001b[0;32m      7\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m letter \u001b[38;5;129;01min\u001b[39;00m vowels:\n\u001b[1;32m----> 8\u001b[0m         found[letter] \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m\n\u001b[0;32m     10\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m k,v \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28msorted\u001b[39m(found\u001b[38;5;241m.\u001b[39mitems()):\n\u001b[0;32m     11\u001b[0m     \u001b[38;5;28mprint\u001b[39m(k,\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mwas found\u001b[39m\u001b[38;5;124m'\u001b[39m,v,\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mtime(s).\u001b[39m\u001b[38;5;124m'\u001b[39m)\n",
      "\u001b[1;31mKeyError\u001b[0m: 'a'"
     ]
    }
   ],
   "source": [
    "vowels = ['a','e','i','o','u']\n",
    "word = input(\"Provide a word to search for vowels:\")\n",
    "\n",
    "found = {} \n",
    "\n",
    "for letter in word:\n",
    "    if letter in vowels:\n",
    "        found[letter] +=1\n",
    "        \n",
    "for k,v in sorted(found.items()):\n",
    "    print(k,'was found',v,'time(s).')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "af0742e9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide a word to search for vowels:apples\n",
      "a was found 1 time(s).\n",
      "e was found 1 time(s).\n"
     ]
    }
   ],
   "source": [
    "vowels = ['a','e','i','o','u']\n",
    "word = input(\"Provide a word to search for vowels:\")\n",
    "\n",
    "found = {}  \n",
    "\n",
    "for letter in word:\n",
    "    if letter in vowels:\n",
    "        found.setdefault(letter,0)  # 不用再提前初始化字典中的所有数据行\n",
    "        found[letter] +=1\n",
    "        \n",
    "for k,v in sorted(found.items()):\n",
    "    print(k,'was found',v,'time(s).')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "fb360f4d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'a', 'e', 'i', 'o', 'u'}"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vowels = {'a','e','e','i','o','u','u'} # 没有了重复值\n",
    "vowels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "69bb323f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'a', 'e', 'i', 'o', 'u'}"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 集合方法 set\n",
    "vowels2 = set('aeeiouu')\n",
    "vowels2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "68d91c3f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'a', 'e', 'h', 'i', 'l', 'o', 'u'}"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# union合并集合方法\n",
    "vowels = set('aeiou')\n",
    "word = 'hello'\n",
    "u = vowels.union(set(word))\n",
    "u"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "6fe0d65f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['a', 'e', 'h', 'i', 'l', 'o', 'u']"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "u_list = sorted(list(u))\n",
    "u_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "852e0991",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'a', 'i', 'u'}"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# difference告诉哪些不是共有元素\n",
    "d = vowels.difference(set(word))\n",
    "d"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "67565594",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'e', 'o'}"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# intersection报告共同对象\n",
    "i = vowels.intersection(set(word))\n",
    "i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "61dcf57c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide a word to search for vowels:elegance\n",
      "e\n",
      "a\n"
     ]
    }
   ],
   "source": [
    "vowels = ['a','e','i','o','u']\n",
    "word = input(\"Provide a word to search for vowels:\")\n",
    "found = [] \n",
    "for letter in word:\n",
    "    if letter in vowels:\n",
    "        if letter not in found:\n",
    "            found.append(letter)\n",
    "for vowel in found:\n",
    "    print(vowel)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "ced7d724",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide a word to search for vowels:elegance\n",
      "e\n",
      "a\n"
     ]
    }
   ],
   "source": [
    "vowels = set('aeiou')   # 用 set 创建一个元音集合\n",
    "word = input(\"Provide a word to search for vowels:\")\n",
    "found = vowels.intersection(set(word)) # intersection 取一个集合的对象，与另一个集合中的对象进行比较，报告找到的共同对象\n",
    "for vowels in found:\n",
    "    print(vowels)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "821c49c3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "list"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 列表用中括号\n",
    "vowels = ['a','e','i','o','u']\n",
    "type(vowels)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "294b5b39",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tuple"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 元组用小括号\n",
    "vowels = ('a','e','i','o','u') \n",
    "type(vowels)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a4a64db3",
   "metadata": {},
   "source": [
    "## 元组是不可变的\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "5de64fa5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['a', 'e', 'I', 'o', 'u']"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 列表可变\n",
    "vowels[2] = 'I'\n",
    "vowels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "36b8498c",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'tuple' object does not support item assignment",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [37]\u001b[0m, in \u001b[0;36m<cell line: 2>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[38;5;66;03m# 元组不可变\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m vowels[\u001b[38;5;241m2\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mI\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[0;32m      3\u001b[0m vowels\n",
      "\u001b[1;31mTypeError\u001b[0m: 'tuple' object does not support item assignment"
     ]
    }
   ],
   "source": [
    "# 元组不可变\n",
    "vowels[2] = 'I'\n",
    "vowels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "9da49aed",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('a', 'e', 'i', 'o', 'u')"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vowels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "bcc565f1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "t = ('Python')\n",
    "print(type(t))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "94f47745",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Python'"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "de84d97a",
   "metadata": {},
   "outputs": [],
   "source": [
    "t2 = ('Python',)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "374dae9a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tuple"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(t2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "80b34632",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('Python',)"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4508790e",
   "metadata": {},
   "source": [
    "# 结合内置数据结构"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "fc5be195",
   "metadata": {},
   "outputs": [],
   "source": [
    "person3 = { 'Name': 'ford Prefect',\n",
    "            'Gender': 'Male', \n",
    "            'Occupation': 'Researcher',\n",
    "            'Home Planet': 'Betelgeuse Seven' }"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "0e450cef",
   "metadata": {},
   "outputs": [],
   "source": [
    "people = {}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "13441abe",
   "metadata": {},
   "outputs": [],
   "source": [
    "people['Ford'] = { 'Name': 'ford Prefect',\n",
    "                   'Gender': 'Male', \n",
    "                   'Occupation': 'Researcher',\n",
    "                   'Home Planet': 'Betelgeuse Seven'}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "0a4ceff1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Ford': {'Name': 'ford Prefect',\n",
       "  'Gender': 'Male',\n",
       "  'Occupation': 'Researcher',\n",
       "  'Home Planet': 'Betelgeuse Seven'}}"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "people"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "58672795",
   "metadata": {},
   "outputs": [],
   "source": [
    "people['Arthur'] =  { 'Name': 'Arthur Dent',\n",
    "                      'Gender': 'Male', \n",
    "                      'Occupation': 'Sandwich-Maker',\n",
    "                      'Home Planet': 'Earth'}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "c091662d",
   "metadata": {},
   "outputs": [],
   "source": [
    "people['Trillian'] =  { 'Name': 'Tricia McMillan',\n",
    "                      'Gender': 'Female', \n",
    "                      'Occupation': 'Mathematician',\n",
    "                      'Home Planet': 'Earth'}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "d993d8f5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Ford': {'Name': 'ford Prefect',\n",
       "  'Gender': 'Male',\n",
       "  'Occupation': 'Researcher',\n",
       "  'Home Planet': 'Betelgeuse Seven'},\n",
       " 'Arthur': {'Name': 'Arthur Dent',\n",
       "  'Gender': 'Male',\n",
       "  'Occupation': 'Sandwich-Maker',\n",
       "  'Home Planet': 'Earth'},\n",
       " 'Trillian': {'Name': 'Tricia McMillan',\n",
       "  'Gender': 'Female',\n",
       "  'Occupation': 'Mathematician',\n",
       "  'Home Planet': 'Earth'}}"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "people"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "1cc2710d",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pprint"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "01210d1f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'Arthur': {'Gender': 'Male',\n",
      "            'Home Planet': 'Earth',\n",
      "            'Name': 'Arthur Dent',\n",
      "            'Occupation': 'Sandwich-Maker'},\n",
      " 'Ford': {'Gender': 'Male',\n",
      "          'Home Planet': 'Betelgeuse Seven',\n",
      "          'Name': 'ford Prefect',\n",
      "          'Occupation': 'Researcher'},\n",
      " 'Trillian': {'Gender': 'Female',\n",
      "              'Home Planet': 'Earth',\n",
      "              'Name': 'Tricia McMillan',\n",
      "              'Occupation': 'Mathematician'}}\n"
     ]
    }
   ],
   "source": [
    "pprint.pprint(people)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "b1f882db",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Name': 'Arthur Dent',\n",
       " 'Gender': 'Male',\n",
       " 'Occupation': 'Sandwich-Maker',\n",
       " 'Home Planet': 'Earth'}"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "people['Arthur']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "64b3345b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Sandwich-Maker'"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "people['Arthur']['Occupation']"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
